<template>
	<view class="viewDetailsPage">
		<view class="viewDetailsTop flex-column border-bottom-f7f7f7">
			<view class="flex-column  ">
				<image class="avatar" :src="withdrawal.avatar" mode=""></image>
				<view class="padding_20rpx_0">
					手机号: {{withdrawal.phone}}
				</view>
				<view style="color: rgb(255, 0, 0);" class="font-weight_bold  ">
					￥{{withdrawal.amount}}
				</view>
			</view>

		</view>
		<view class="padding_40rpx  viewDetails ">

			<view class="flex-between padding-bottom_40rpx">
				<view style="color: rgb(0, 0, 0);">
					提现单号：
				</view>
				<view class="font-overflow" style="color: rgb(80, 77, 78);">
					<text>{{withdrawal.sn_order}}</text>
				</view>
			</view>
			<view class="flex-between padding-bottom_40rpx">
				<view style="color: rgb(0, 0, 0);">
					提现方式：
				</view>
				<view class="font-overflow" style="color: rgb(80, 77, 78);">
					{{withdrawal.pay_mode==1?'微信':'支付宝'}}
				</view>
			</view>
			<view class="flex-between padding-bottom_40rpx">
				<view style="color: rgb(0, 0, 0);">
					实际到账金额：
				</view>
				<view class="font-overflow font-weight_bold" style="color: rgb(255, 0, 0);">
					{{withdrawal.reality_amount}}
				</view>
			</view>
			<view class="flex-between padding-bottom_40rpx">
				<view style="color: rgb(0, 0, 0);">
					提现手续费：
				</view>
				<view class="font-overflow font-weight_bold" style="color: rgb(255, 0, 0);">
					{{withdrawal.fees_ratio}}%
				</view>
			</view>
			<view class="flex-between padding-bottom_40rpx">
				<view style="color: rgb(0, 0, 0);">
					提现手续费金额：
				</view>
				<view class="font-overflow font-weight_bold" style="color: rgb(255, 0, 0);">
					{{(withdrawal.amount*(withdrawal.fees_ratio/100)).toFixed(3)}}
					
				</view>
			</view>
			<view class="flex-between ">
				<view style="color: rgb(0, 0, 0);">
					申请时间：
				</view>
				<view class="font-overflow" style="color: rgb(80, 77, 78);">
					<text>{{withdrawal.create_time}}</text>
				</view>
			</view>


		</view>
		<view class="padding_40rpx  margin-top_20rpx background-color_FFFFFF">
			<text class="font-weight_bold " style="min-width: 130rpx;font-size: 28rpx;">备注内容</text>
			<view class="margin-top_20rpx">
				<view class="uni-textarea">
					<textarea v-model="form.remark" :disabled="withdrawal.status==4||withdrawal.status==3?true:false" placeholder-style="color:#999;"
						placeholder="同意或者拒绝时候要说的文字" />
				</view>
			</view>
		</view>

		<view class="flex-between bottomFixed margin-top_20rpx" v-if="withdrawal.status==1||withdrawal.status==2">
			<view class="reset flex "  @click="withdrawalReject()">
				审核驳回
			</view>
			<view class="confirm flex" @click="confirmPayment()">
				确认打款
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				tabIndex: 4,
				form: {
					feedbackContent: ''
				},
				withdrawal:null,
				token: uni.getStorageSync('login').token,
				form:{
					id:'',
					remark:''
				}
				
			}
		},
		onLoad(options) {
          console.log(options)
		  this.withdrawal=options
		  // 获取用户详情
		 
		  console.log(options)
		  this.form.id=options.id
		   this.form.remark=options.remark
		},
		
		methods: {
			confirmPayment(){
				uni.showModal({
					title: '提示',
					content: this.withdrawal.pay_mode==1?'确定微信打款':'确定支付宝打款' ,
					success: async (res) => {
						if (res.confirm) {
				
							this.$at.uniDoFunc({
								key: 'submitPay',
								success: async () => {
									this.$at.lockKey('submitPay');
									// 登录 需要进行判断当前账号密码 和账号归属店铺及角色是否又选择
									console.log((this.form))
															
									const res = await this.$http.post({
										url: this.$api.withdrawalPass,
										data: {
													
											id:this.form.id
										},
										headers: {
											'Authorization': `Bearer ${this.token}`
										}
													
									})
									console.log(res)
									if (res.code == 0) {
													
													
													
										// 跳转到登录页面
										this.$at.releaseKey('submitPay');
										this.$sun.toast(res.msg, 'none')
													
										 setTimeout(()=>{
											 this.$sun.navBack()
										 },500)
									} else {
										this.$at.releaseKey('submitPay');
										this.$sun.toast(res.msg, 'none')
									}
							
								}
							});
						} else if (res.cancel) {
				
						}
					}
				});
				
				
				
			},
			
            withdrawalReject(){
				this.$at.uniDoFunc({
					key: 'submit',
					success: async () => {
						this.$at.lockKey('submit');
						// 登录 需要进行判断当前账号密码 和账号归属店铺及角色是否又选择
						if (!this.form.remark) {
							this.$sun.toast("请输入驳回原因", 'none')
							this.$at.releaseKey('submit');
						}  else {
				
				
							console.log((this.form))
						
							const res = await this.$http.post({
								url: this.$api.withdrawalReject,
								data: {
				
									...this.form
								},
								headers: {
									'Authorization': `Bearer ${this.token}`
								}
				
							})
							console.log(res)
							if (res.code == 0) {
				
				
				
								// 跳转到登录页面
								this.$at.releaseKey('submit');
								this.$sun.toast(res.msg, 'none')
				
								 setTimeout(()=>{
									 this.$sun.navBack()
								 },500)
							} else {
								this.$at.releaseKey('submit');
								this.$sun.toast(res.msg, 'none')
							}
						}
				
					}
				});
			}
		}
	}
</script>

<style lang="less" scoped>
	.viewDetailsPage {
		.viewDetailsTop {
			width: 750rpx;
			padding: 40rpx 0;
			background: rgb(255, 255, 255);

			.avatar {
				width: 116rpx;
				height: 116rpx;
			}
		}

		.viewDetails {
			background: rgb(255, 255, 255);
		}

	}

	.bottomFixed {
		background: rgb(255, 255, 255);
		padding: 18rpx;
		height: 128rpx;
		position: fixed;
		bottom: 0;
		width: 750rpx;

		.reset {
			width: 260rpx;
			height: 88rpx;
			background: rgb(255, 0, 0);
			color: rgb(255, 255, 255);
		}

		.confirm {
			width: 428rpx;
			height: 88rpx;
			background-color: rgb(42, 137, 255);
			color: rgb(255, 255, 255);

			font-size: 32rpx;
			font-weight: 400;
		}
	}

	page {
		background: #f6f6f6;
	}
</style>